package com.shangjinrong.controller.site;

import com.shangjinrong.domain.LendItemReturn;
import com.shangjinrong.result.R;
import com.shangjinrong.service.LendItemReturnService;
import com.shangjinrong.util.JwtUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author Naruto
 */


@RestController
@RequestMapping("site/lendItemReturn")
@CrossOrigin
public class SiteLendItemReturnController {


    @Autowired
    private LendItemReturnService lendItemReturnService;

    @GetMapping("getLendItemReturnList/{lendId}")
    public R getLendItemReturnByLendId(@PathVariable Long lendId, HttpServletRequest request) {

        String token = request.getHeader("token");

        Long userId = JwtUtils.getUserId(token);

        List<LendItemReturn> lendItemReturnList = lendItemReturnService.selectByLendId(lendId, userId);

        return R.ok().data("list", lendItemReturnList);
    }

}
